package com.drink.yan.web.rest;

import com.drink.yan.intf.entity.*;
import com.drink.yan.intf.vo.RecruitUserSummaryVo;
import com.drink.yan.intf.vo.SchoolAdjustVo;
import com.drink.yan.intf.vo.SchoolRecruitVo;
import com.drink.yan.intf.vo.SchoolUserAdjustVo;
import com.drink.yan.svc.service.YanSchoolService;
import com.drink.yan.web.rest.req.qry.*;
import com.meta.framework.common.core.controller.BaseController;
import com.meta.framework.common.core.page.TableResponseVo;
import com.meta.framework.core.ResponseVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * java类简单作用描述
 *
 * @Title:
 * @Package: com.drink.yan.web.rest.app.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2023/11/23 14:58
 * @Version: v2.0
 */
@RestController
@RequestMapping("/school")
public class SchoolRest extends BaseController {

    @Resource
    private YanSchoolService yanSchoolService;

    @ApiOperation(value = "查询院校", notes = "查询院校", tags = {"学生小程序","PC"})
    @GetMapping("/list")
    public TableResponseVo<List<YanSchool>> listSchool(PageSchoolQry qry){
        if(Objects.isNull(qry.getOrderByColumn())){
            qry.setOrderByColumn("school_id");
            qry.setIsAsc("asc");
        }
        startPage();
        List<YanSchool> list = yanSchoolService.listSchool(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "查询院校,下拉框使用", notes = "查询院校，下拉框使用", tags = {"学生小程序","PC"})
    @GetMapping("/map")
    public ResponseVo<Map<Long, String>> listSchoolMap(){
        Map<Long, String> map = yanSchoolService.listSchoolMap();
        return ResponseVo.success(map);
    }

    @ApiOperation(value = "查询院校招录专业,下拉框使用", notes = "查询院校招录专业,下拉框使用", tags = {"学生小程序"})
    @GetMapping("/map/spe")
    public ResponseVo<Map<String, String>> listSchoolSpe(PageSchoolSpeQry qry){
        startPage();
        Map<String, String> map = yanSchoolService.listSchoolSpe(qry);
        return ResponseVo.success(map);
    }

    @ApiOperation(value = "院校详情", notes = "院校详情", tags = {"PC"})
    @GetMapping("/detail/{schoolId}")
    public ResponseVo<YanSchool> SchoolDetail(@PathVariable Long schoolId){
        return ResponseVo.success(yanSchoolService.getSchoolDetail(schoolId));
    }

    @ApiOperation(value = "保存院校", notes = "保存院校", tags = {"PC"})
    @PostMapping("/save")
    public ResponseVo<YanSchool> SchoolDetail(@RequestBody YanSchool school){
        return ResponseVo.success(yanSchoolService.saveSchool(school));
    }

    @ApiOperation(value = "查询招录", notes = "查询招录", tags = {"学生小程序","PC"})
    @GetMapping("/recruit")
    public TableResponseVo<List<SchoolRecruitVo>> listSchoolRecruit(ListSchoolSpeQry listSchoolSpeQry){
        startPage();
        List<SchoolRecruitVo> list = yanSchoolService.listSchoolRecruit(listSchoolSpeQry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "查询院校专业", notes = "查询院校专业", tags = {"学生小程序","PC"})
    @GetMapping("/spe")
    public TableResponseVo<List<SchoolRecruitVo>> listSchoolSpe(ListSchoolSpeQry listSchoolSpeQry){
        startPage();
        List<SchoolRecruitVo> list = yanSchoolService.listSchoolSpe(listSchoolSpeQry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "保存招录", notes = "保存招录", tags = {"PC"})
    @PostMapping("/recruit/save")
    public ResponseVo<YanSchoolRecruit> save(@RequestBody YanSchoolRecruit yanSchoolRecruit){
        return ResponseVo.success(yanSchoolService.saveSchoolRecruit(yanSchoolRecruit));
    }

    @ApiOperation(value = "招录详情", notes = "招录详情", tags = {"PC"})
    @GetMapping("/recruit/detail/{recruitId}")
    public ResponseVo<YanSchoolRecruit> SchoolRecruitDetail(@PathVariable Long recruitId){
        return ResponseVo.success(yanSchoolService.getSchoolRecruitDetail(recruitId));
    }

    @ApiOperation(value = "查询调剂", notes = "查询调剂", tags = {"学生小程序","PC"})
    @GetMapping("/adjust")
    public TableResponseVo<List<SchoolAdjustVo>> listSchoolAdjust(ListSchoolSpeQry listSchoolSpeQry){
        startPage();
        List<SchoolAdjustVo> list = yanSchoolService.listSchoolAdjust(listSchoolSpeQry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "保存调剂", notes = "保存调剂", tags = {"PC"})
    @PostMapping("/adjust/save")
    public ResponseVo<YanSchoolAdjust> save(@RequestBody YanSchoolAdjust cmd){
        return ResponseVo.success(yanSchoolService.saveSchoolAdjust(cmd));
    }

    @ApiOperation(value = "调剂详情", notes = "调剂详情", tags = {"PC"})
    @GetMapping("/adjust/detail/{adjustId}")
    public ResponseVo<YanSchoolRecruit> SchoolAdjustDetail(@PathVariable Long adjustId){
        return ResponseVo.success(yanSchoolService.getSchoolAdjustDetail(adjustId));
    }

    @ApiOperation(value = "查询复试", notes = "查询复试", tags = {"学生小程序","PC"})
    @GetMapping("/retest")
    public TableResponseVo<List<YanSchoolRetest>> listSchoolRetest(ListSchoolSpeQry listSchoolSpeQry){
        startPage();
        List<YanSchoolRetest> list = yanSchoolService.listSchoolRetest(listSchoolSpeQry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "保存复试", notes = "保存复试", tags = {"PC"})
    @PostMapping("/retest/save")
    public ResponseVo<YanSchoolRetest> save(@RequestBody YanSchoolRetest cmd){
        return ResponseVo.success(yanSchoolService.saveSchoolRetest(cmd));
    }

    @ApiOperation(value = "复试详情", notes = "复试详情", tags = {"PC"})
    @GetMapping("/retest/detail/{retestId}")
    public ResponseVo<YanSchoolRetest> schoolRetestDetail(@PathVariable Long retestId){
        return ResponseVo.success(yanSchoolService.getSchoolRetestDetail(retestId));
    }

    @ApiOperation(value = "查询录取人员", notes = "查询录取人员", tags = {"学生小程序","PC"})
    @GetMapping("/recruit/user/list")
    public TableResponseVo<List<YanSchoolRecruitUser>> listSchoolRecruitUser(ListRecruitUserQry qry){
        startPage();
        List<YanSchoolRecruitUser> list = yanSchoolService.listSchoolRecruitUser(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "保存录取人员", notes = "保存录取人员", tags = {"PC"})
    @PostMapping("/recruit/user/save")
    public ResponseVo<YanSchoolRecruitUser> save(@RequestBody YanSchoolRecruitUser cmd){
        return ResponseVo.success(yanSchoolService.saveSchoolRecruitUser(cmd));
    }

    @ApiOperation(value = "录取人员详情", notes = "录取人员详情", tags = {"PC"})
    @GetMapping("/recruit/user/detail/{recruitUserId}")
    public ResponseVo<YanSchoolRecruitUser> getSchoolRecruitUserDetail(@PathVariable("recruitUserId") Long recruitUserId){
        return ResponseVo.success(yanSchoolService.schoolRecruitUserDetail(recruitUserId));
    }

    @ApiOperation(value = "就业方向", notes = "就业方向", tags = {"学生小程序"})
    @GetMapping("/special/work/{specialCode}")
    public ResponseVo<Object> specialWork(@PathVariable String specialCode){
        return ResponseVo.success(yanSchoolService.specialWork(specialCode));
    }

    @ApiOperation(value = "查询省份分区", notes = "查询省份分区", tags = {"学生小程序"})
    @GetMapping("/province/area")
    public ResponseVo<Map<String, List<String>>> schoolProvinceArea(){
        return ResponseVo.success(yanSchoolService.schoolProvinceArea());
    }


    @ApiOperation(value = "国家线", notes = "国家线", tags = {"学生小程序"})
    @GetMapping("/listGjx")
    public ResponseVo<List<YanSpecialGjx>> ListSpecialGjx(SpecialGjxQry qry){
        return ResponseVo.success(yanSchoolService.listSpecialGjx(qry));
    }

    @ApiOperation(value = "专业录取概要", notes = "专业录取概要", tags = {"学生小程序"})
    @GetMapping("/summary/recruit/list")
    public ResponseVo<List<RecruitUserSummaryVo>> ListRecruitUserSummary(SchoolRecruitQry qry){
        return ResponseVo.success(yanSchoolService.listRecruitUserSummary(qry));
    }

    @ApiOperation(value = "一分一段年份查询", notes = "一分一段年份查询", tags = {"学生小程序"})
    @GetMapping("/year/adjust/list")
    public ResponseVo<List<SchoolUserAdjustVo>> listUserAdjust(PageUserAdjustQry qry){
        return ResponseVo.success(yanSchoolService.listUserAdjust(qry));
    }

}
